// Level.h -- Level Class Header for reading Lemmings levels (*.lvl)
// Copyright (C) 2007, 2008  Brett McLarnon, Morgan Conbere
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
// USA.
//
// $Id: Level.h 13 2008-09-02 06:02:03Z mconbere $
//

#ifndef __LEVEL_LEVEL_H__
#define __LEVEL_LEVEL_H__

#include <stdint.h>
#include <string>
#include <vector>

namespace level
{

static const int cNumSkills = 8;
    
enum Skill
{
    Climber,
    Floater,
    Bomber,
    Blocker,
    Builder,
    Basher,
    Miner,
    Digger
};
    
enum Tileset
{
    Dirt,
    Fire,
    Squasher,
    Pillar,
    Crystal,
    Brick,
    Rock,
    Snow,
    Bubble
};

// These would be an enum, but c++ hates enums,
// since these are used bitwise
static const uint32_t None = 0;
static const uint32_t Remove = 2;
static const uint32_t Flip = 4;
static const uint32_t OnlyTerrain = 4;
static const uint32_t NoOverwrite = 8;

struct Object
{
    int32_t x;
    int32_t y;
    uint8_t id;
    uint32_t modifier;
};

struct Terrain
{
    int32_t x;
    int32_t y;
    uint32_t modifier;
    uint8_t id;
};

struct Steel
{
    int32_t x;
    int32_t y;
    uint32_t height;
    uint32_t width;
};

class Level
{
public:
    Level(std::istream &in);
    void print(std::ostream &out);

private:
    std::string mName;
    size_t mReleaseRate;
    size_t mLemmingCount;
    size_t mLemmingRescue;
    size_t mTimeLimit;
    size_t mSkills[cNumSkills];
    size_t mScreenStart;
    Tileset mTileset;
    size_t mLevelWidth;
    std::vector<Object> mObjects;
    std::vector<Terrain> mTerrain;
    std::vector<Steel> mSteel;
};

} // namespace level

#endif // __LEVEL_LEVEL_H__